package org.jfk.core.interceptor;

import org.apache.log4j.Logger;
import org.jfk.core.controller.BaseController;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
/**
 * 异常处理拦截器
 * @author Administrator jiangxf
 *
 */
public class ExceptionInterceptor implements Interceptor {
	private static Logger logger = Logger.getLogger(ExceptionInterceptor.class);
	
	@Override
	public void intercept(Invocation inv) {
		try{
			inv.invoke();
		}catch(Exception ex){
			logger.error(ex.getMessage(), ex);
			BaseController bc = (BaseController)inv.getController();
			bc.returnError(bc.getAttr("errMsg").toString());
		}
	}
}
